package test;

import java.util.*;

public class Aiqiyi3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        if (getRes(str)){
            System.out.println("True");
        }else {
            System.out.println("False");
        }
    }

    private static boolean getRes(String str) {
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < str.length(); i++) {
            if (stack.empty()){
                if (str.charAt(i) == ')' || str.charAt(i) == '}' || str.charAt(i) == ']'){
                    return false;
                }
                stack.add(str.charAt(i));
            }else{
                if (str.charAt(i) == '(' || str.charAt(i) == '{' || str.charAt(i) == '['){
                    stack.add(str.charAt(i));
                    continue;
                }
                if (stack.peek() == '(' && str.charAt(i) == ')'){
                    stack.pop();
                    continue;
                }
                if (stack.peek() == '{' && str.charAt(i) == '}'){
                    stack.pop();
                    continue;
                }
                if (stack.peek() == '[' && str.charAt(i) == ']'){
                    stack.pop();
                }
            }
        }

        return stack.isEmpty();
    }

}
